package com.example.jetpackdemo.viewmodel

import android.content.Context
import android.util.Log
import com.example.jetpackdemo.common.BaseConstant
import com.example.jetpackdemo.db.RepositoryProvider
import com.example.jetpackdemo.db.repository.FavouriteShoeRepository
import com.example.jetpackdemo.db.repository.ShoeRepository
import com.example.jetpackdemo.db.repository.UserRepository
import com.example.jetpackdemo.utils.AppPrefsUtils
import com.example.jetpackdemo.viewmodel.factory.*

object CustomViewModelProvider {


    fun providerRegisterModel(context: Context): RegisterModelFactory {
        val repository: UserRepository = RepositoryProvider.providerUserRepository(context)
        return RegisterModelFactory(repository)
    }

    fun providerLoginModel(context: Context): LoginModelFactory {
        val repository: UserRepository = RepositoryProvider.providerUserRepository(context)
        return LoginModelFactory(repository)
    }

    fun providerShoeModel(context: Context): ShoeModelFactory {
        val repository: ShoeRepository = RepositoryProvider.providerShoeRepository(context)
        return ShoeModelFactory(repository)
    }

    fun providerFavouriteModel(context: Context): FavouriteModelFactory {
        val repository: ShoeRepository = RepositoryProvider.providerShoeRepository(context)
        val userId: Long = AppPrefsUtils.getLong(BaseConstant.SP_USER_NAME)
        return FavouriteModelFactory(repository, userId)
    }

    fun providerMeModel(context: Context) {

    }


    fun providerDetailModel(context: Context,shoeId:Long,userId:Long):FavouriteShoeModelFactory{
        val repository: ShoeRepository = RepositoryProvider.providerShoeRepository(context)
        val favShoeRepository: FavouriteShoeRepository = RepositoryProvider.providerFavouriteShoeRepository(context)
        return FavouriteShoeModelFactory(repository, favShoeRepository, shoeId, userId)
    }

}